﻿using System;
using System.Collections.Generic;
using System.Linq;
using jQueryApi;

namespace TuringMachine
{
   public abstract class HtmlGeneric
   {
      protected jQueryObject m_object;
      protected string m_id;

      public string pId
      {
         get { return m_id; }
      }

      public jQueryObject pObject
      {
         get { return m_object; }
         set { m_object = value; }
      }


      public int pPosX
      {
         get { return m_object.Position().Left; }
         set { m_object.CSS("left", value + "px"); }
      }

      public int pPosY
      {
         get { return m_object.Position().Top; }
         set { m_object.CSS("top", value + "px"); }
      }

      public bool pVisible
      {
         get
         {
            if (pObject.GetCSS("display") == "none")
               return false;
            else
               return true;
         }
         set
         {
            if (value != pVisible)
            {
               if (value) 
                  pObject.Show();
               else
                  pObject.Hide();
            }
         }
      }


   }

   public class Div:HtmlGeneric
   {

      public Div(jQueryObject parent, string id)
      {
         string suffix = IdFactory.GetId();
         m_id = id + suffix;
         parent.Append("<div id=\"" + m_id + "\"></div>");
         m_object = parent.Children("#" + m_id);
         m_object.CSS("position", "absolute");
      }
   }

   public class Span : HtmlGeneric
   {

      public Span(jQueryObject parent, string id)
      {
         string suffix = IdFactory.GetId();
         m_id = id + suffix;
         parent.Append("<span id=\"" + m_id + "\"></span>");
         m_object = parent.Children("#" + m_id);
         m_object.CSS("position", "absolute");
      }
   }

}
